import VueRouter from 'vue-router'
import guides from "./guides";
import resourceGuides from "./resourceGuides";

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [
    // 由于常德自建库的风格与长沙县的不一致,故无法像长沙县那样为每个导航栏设置子路由
    //导航页面
    {
        name:'home',
        path: '/',
        component: () => import("../templates/main/Main"),
        children: [
            {
                path: 'Index',
                component: () => import("../page/guides/Index")
            },
            ...guides,
        ]
    },
    //账号登录注册
    {
        //账号
        path: '/account',
        component: () => import("../page/login/index"),
        name: "LoginIndex",
        children: [
            {
                path: 'login',
                component: () => import("../page/login/LoginForm")
            },
            {
                path: 'register',
                component: () => import("../page/login/RegisterForm.vue")
            }
        ]
    },
    //二级导航
    {
        name:'ResourceGuides',
        path: '/ResourceGuides',
        component: () => import("../templates/SecondePageTemplates/SourceDisplayTemplate"),
        children: [
            ...resourceGuides
        ]
    },

    //内容展示
    {
        path: '/ContentDisplay',
        component: () => import("../templates/SecondePageTemplates/ConcreteContentDisplayTemplate"),
        children: [
            //视频播放
            {
                name: 'VideoDetail',
                path: 'VideoPlay/:id',
                component: () => import("../templates/details/videoDetailPageTemplate")
            },
            // 书籍阅读详情页
            {
                name:'BookDetail',
                path: 'BookDetail/:id',
                component: () => import('../templates/details/bookDetailPageTemplate')
            },
            // 报纸阅读详情页
            {
                name:'NewspaperDetail',
                path: 'NewspaperDetail/:id',
                component: () => import('../templates/details/newspaperDetailPageTemplate')
            }

        ]
    },
    {
        // 搜索页
        name:'search',
        path:'/Search/:keyword',
        component: () => import('../page/SearchPage')
    }


]


export default new VueRouter({
    mode: 'history',
    routes: routes
})
